﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class operate_changeInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        string[] keys = Request.QueryString.AllKeys;
        if (Request.QueryString[keys[0]].ToString().Trim() == "tb_student")
        {
            List<string> set = new List<string>();
            for (int i = 2; i < keys.Length-1; i++)
            {
                set.Add(String.Format(" {0} = '{1}' ", keys[i], Request.QueryString[keys[i]]));
            }
            string s = string.Join(" , ", set);
            string sql = "update  tb_student set " + s
                + ", major_id = (select major_id from tb_major where " + String.Format(" {0} = '{1}' ", keys[7], Request.QueryString[keys[7]]) + ")"
                + " where student_id = '" + Request.QueryString[keys[1]] + "'";
            int k = SqlServer.ExecuteNonQuery(sql);
            if (k > 0)
            {
                Response.Write(k.ToString());
            }
            else
            {
                Response.Write("0");//删除失败
            }
            Response.End();
        }

    }
}